<template>
  <div class="article-page">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item>面经后台</el-breadcrumb-item>
      <el-breadcrumb-item>面经管理</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card shadow="never" border="false">
      <template #header>
        <div class="header">
          <span>共 300 条记录</span>
          <el-button
            icon="el-icon-plus"
            size="small"
            type="primary"
            round>
            添加面经
          </el-button>
        </div>
      </template>
      <!--
        el-table 属性
          data: 表格数据, 必须是一个数组
        el-table-column
          width: 宽度
          label: 表头的文字
          prop: 字符串类型, 要在此列渲染的数据属性名
       -->
       <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        prop="date"
        label="日期"
        width="180">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="180">
      </el-table-column>
      <el-table-column
        label="性别"
        width="120">
        <template v-slot="{ row }">
          {{ row.gender ? '男': '女' }}
        </template>
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址">
      </el-table-column>
      <el-table-column
      label="操作"
      width="120">
        <template v-slot="scope">
          <el-button @click="handleClick(scope.row)" type="button">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  name: 'article-page',
  data () {
    return {
      tableData: [{
        date: '2016-05-02',
        name: '马小翔',
        address: '上海市普陀区金沙江路 1518 弄',
        gender: 1
      }, {
        date: '2016-05-04',
        name: '杨小雪',
        address: '上海市普陀区金沙江路 1517 弄',
        gender: 0
      }, {
        date: '2016-05-01',
        name: '鲁小爽',
        address: '上海市普陀区金沙江路 1519 弄',
        gender: 1
      }, {
        date: '2016-05-03',
        name: '周小雷',
        address: '上海市普陀区金沙江路 1516 弄',
        gender: 1
      }]
    }
  },
  created () {
    // this.tableData
    // this.tableData.forEach(item => {
    //   if (item.gender === 1) {
    //     item.gender = '男'
    //   } else {
    //     item.gender = '女'
    //   }
    // })
  },
  methods: {
    handleClick (row) {
      console.log(row)
      this.tableData.splice(row.$index, 1)
    }
  }
}
</script>

<style lang="scss" scoped>
.el-card {
  margin-top: 25px;
  .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-right: 16px;
  }
  .actions {
    font-size: 18px;
    display: flex;
    justify-content: space-around;
    color: #666;
    > i:hover {
      color: rgba(114, 124, 245, 1);
      cursor: pointer;
    }
  }
}
.el-pagination {
  margin-top: 20px;
  text-align: center;
}
.el-breadcrumb {
  margin-top: 10px;
}
.el-form {
  padding-right: 40px;
}
.quill-editor {
  ::v-deep .ql-editor {
    height: 300px;
  }
}
.el-rate {
  padding: 10px 0;
}
.article-preview {
  padding: 0 40px 40px 40px;
  > h5 {
    font-size: 20px;
    color: #666;
    border-bottom: 1px dashed #ccc;
    padding-bottom: 30px;
    margin: 0 0 20px 0;
  }
}
</style>
